@echo off
REM This batch file runs 'npm run build' and then compresses specific files using Bandizip

REM Define the path to Bandizip command line tool
set BANDIZIP_PATH="F:\Bandizip\Bandizip.exe"

REM Define the output archive name on the desktop
set OUTPUT_ARCHIVE=%USERPROFILE%\Desktop\dist.zip

REM Delete the existing archive if it exists
if exist "%OUTPUT_ARCHIVE%" (
    echo Deleting existing archive: %OUTPUT_ARCHIVE%
    del "%OUTPUT_ARCHIVE%"
)

REM Run npm build
npm run build

REM Check if build was successful
if %ERRORLEVEL% neq 0 (
    echo Build failed with error code %ERRORLEVEL%
    exit /b %ERRORLEVEL%
)

REM Compress nuxt-dist, static, package.json, and nuxt.config.js into a zip file
"%BANDIZIP_PATH%" a -y "%OUTPUT_ARCHIVE%" "nuxt-dist" "static" "package.json" "nuxt.config.js" 

echo Build completed and files compressed into "%OUTPUT_ARCHIVE%".